package LC;

import java.util.Scanner;

/**
 * Determine whether an integer is a palindrome. Do this without extra space.
 */
public class LC_009_PalindromeNumber {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int x = sc.nextInt();
            boolean palindrome = Solution.isPalindrome(x);
            System.out.println(palindrome);
        }
        sc.close();
    }

    private static boolean isPalindrome(int x) {
        return new StringBuilder(String.valueOf(x)).reverse().toString().equals(String.valueOf(x));
    }

    static class Solution {
        static boolean isPalindrome(int x) {
            if (x < 0 || (x > 0 && x % 10 == 0)) return false;
            int num = 0;
            while (x > num) {
                num = num * 10 + x % 10;
                x /= 10;
            }
            System.out.println(num);
            return x == num || num / 10 == x;
        }
    }
}
